#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Project ：jira 
# @Author  : hpc
# @File    : utils.py
# @Time    : 2021/6/14 3:35 下午

class Utils(object):
    @staticmethod
    def handle_colon(content, word):
        """处理冒号
        :param content:
        :param word:
        :return:
        """
        # 英文:
        if content.find('{}:'.format(word)) != -1:
            symbol = ':'
        # 中文：
        elif content.find('{}：'.format(word)) != -1:
            symbol = '：'
        else:
            symbol = ''
        data = content.split('{}{}'.format(word, symbol))[1]
        return data

    @classmethod
    def key_word(cls, case_content):
        """处理关键词
        :param case_content:
        :return:
        """
        # 用例库名称或者用例名称
        case_title = case_content.split('-')[0]
        key_word = story = ''
        for filed in case_content.split('-')[1:]:
            if filed.find('关键词') != -1:
                key_word = cls.handle_colon(filed, '关键词')
            if filed.find('需求') != -1:
                story = cls.handle_colon(filed, '需求')
        return case_title, key_word, story
